package com.annotation.config;

import com.annotation.dao.BookDao;
import com.annotation.entities.Red;
import com.annotation.service.BookService;
import com.annotation.typefilter.BookTypeFilter;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.*;

@Configurable
@ComponentScan(basePackages = "com.annotation",useDefaultFilters = false,includeFilters = {@ComponentScan.Filter(type = FilterType.CUSTOM,classes = BookTypeFilter.class)})
@Import(Red.class)
public class MainConfigAutowired {

    @Primary
    @Bean(name = "bookDao2")
    public BookDao bookDao(){
        BookDao bookDao = new BookDao();
        bookDao.setLable(2);
        return bookDao;
    }

    @Bean
    public BookService bookService2(BookDao bookDao){
        BookService bookService = new BookService();
        bookService.setBookDao(bookDao);
        return bookService;
    }

}
